package Stringdemo;

import java.util.Scanner;

public class StringDemo4 {
    public static void main(String[] args) {
        String rightuserName = "weizhihui";
        String rightpassword = "123456";

        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < 3; i++) {
            System.out.print("请输入用户名：");
            String username = sc.next();
            System.out.print("请输入密码：");
            String password = sc.next();

            if (username.equals(rightuserName) && password.equals(rightpassword)) {
                System.out.println("用户登陆成功");
                break;
            }else{
                if (i < 2) {
                    System.out.println("用户登陆失败，用户名或密码有误,您还剩下" + (2 - i) + "次机会");
                }else {
                    System.out.println("用户登陆失败，您的账户已锁定!!!");
                }
            }
        }
    }
}
